﻿
@model DictionaryEntity
@inject IDictionaryService mService
@{

    ViewData["Title"] = "数据字典 编辑";
    Layout = "../Shared/_Layout.cshtml";

}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content text-center p-md">
                    <form id="dynamic-form" asp-action="Edit" method="post" class="form-horizontal" role="form">
                        <div asp-validation-summary="@ValidationSummary.All" class="text-danger"></div>
                        <input type="hidden" asp-for="DictionaryId" />
                        <div class="form-group">
                            <label asp-for="ParentId" class="col-md-3 control-label text-right"> 上级</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"></span>
                                    <select class="select2"  asp-for="ParentId">
                                        <option value="">请选择</option>
                                        @{ 
                                            var lstDic= mService.GetDicByParentId("");
                                            if (lstDic != null && lstDic.Count > 0)
                                            {
                                                foreach (var item in lstDic)
                                                {
                                                    @Html.Raw("<option value=\""+ item.DictionaryId + "\" "+(item.DictionaryId==Model.ParentId?"selected":"") + " >"+ item.KeyName + "</option>")
                                                }
                                            }
                                        }
                                    </select>
                                </div>
                                <span asp-validation-for="ParentId" class="text-danger"></span>
                            </div>

                        </div>
                        <div class="form-group">
                            <label asp-for="KeyName" class="col-md-3 control-label text-right"> 名称</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <input asp-for="KeyName" class="form-control" validate="{required:true  ,maxlength:50   }" />
                                </div>
                                <span asp-validation-for="KeyName" class="text-danger"></span>
                            </div>

                        </div>
                        <div class="form-group">
                            <label asp-for="KeyValue" class="col-md-3 control-label text-right"> 值</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <input asp-for="KeyValue" class="form-control" validate="{required:true  ,IsInt:true    }" />
                                </div>
                                <span asp-validation-for="KeyValue" class="text-danger"></span>
                            </div>

                        </div>
                        <div class="form-group">
                            <label asp-for="OrderNum" class="col-md-3 control-label text-right"> 排序</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">*</span>
                                    <input asp-for="OrderNum" class="form-control" validate="{required:true  ,IsInt:true    }" />
                                </div>
                                <span asp-validation-for="OrderNum" class="text-danger"></span>
                            </div>

                        </div>
                        <div class="form-group">
                            <label asp-for="Remark" class="col-md-3 control-label text-right">描述</label>
                            <div class="col-md-9  text-left">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"></span>
                                    <input asp-for="Remark" class="form-control" validate="{required:false  ,maxlength:2000   }" />
                                </div>
                                <span asp-validation-for="Remark" class="text-danger"></span>
                            </div>

                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <a class="btn btn-white" asp-action="index" >返  回</a>

                                <button class="btn btn-primary" type="submit">保存</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript">
    $(function () {
        $(document).ready(function () {
            $(".form-horizontal").CustomForm({
                isValidate: true,
                isTable: false
            });

	  });
    });
    </script>
}